﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Business.Sales.ProductPrice;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Business.Controllers.Sales
{
    [RemoteService]
    [Route("api/v1/sales/product-prices")]
    public class SaleProductPriceController : BusinessController
    {
        private ISaleProductPriceAppService _appService;

        public SaleProductPriceController(ISaleProductPriceAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<SaleProductPriceDto> GetAsync(Guid id)
        {
            return await _appService.GetAsync(id);
        }

        [HttpGet]
        [Route("products")]
        public async Task<List<SaleProductPriceItemDto>> GetAsync(SaleProductPriceResultRequestDto filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpGet]
        public async Task<PagedResultDto<SaleProductPriceDto>> GetAsync(SaleProductPricePagedResultRequestDto filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPost]
        public async Task<SaleProductPriceDto> CreateAsync(SaleProductPriceCreateDto input)
        {
            return await _appService.CreateAsync(input);
        }

        [HttpPut]
        public async Task<SaleProductPriceDto> UpdateAsync(SaleProductPriceUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
